class Animal{
    private String name;
    private int age;

    public Animal(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public void eat(){
        System.out.println(this.age+"在吃饭");
    }
}
class Dog extends Animal{
    public Dog(String name, int age) {
        super(name, age);
    }

    @Override
    public void eat() {
        System.out.println(this.getName()+"吃狗粮");
    }
}
public class Test {
    public static void main(String[] args) {
        Animal animal=new Dog("旺财",3);//父类引用引用了子类对象
        animal.eat();//通过父类引用访问了和父类同名的子类方法，

    }
}
